//
//  ItemReprotViewController.m
//  SafeFoodManagerDemo
//
//  Created by bob on 2017/11/21.
//  Copyright © 2017年 bob. All rights reserved.
//

#import "ItemReprotViewController.h"
#import "SettingTableViewCell.h"
#import "ItemSmallViewController.h"
#import "ItemLargerViewController.h"
#import "ReportReqModel.h"
#import "TextLabelTableViewCell.h"
#import "AnswerContentTableViewCell.h"
#import "AnswerTitleTableViewCell.h"
#import "QuestionsTableViewCell.h"
#import "ExaminationTableViewCell.h"
#import "StandardAnswerTableViewCell.h"
@interface ItemReprotViewController ()<UITableViewDelegate,UITableViewDataSource>

@property(nonatomic,strong)TB_TableView *homeTableView;

@end

@implementation ItemReprotViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.title=@"检查报告";
    
    [self.view addSubview:self.homeTableView];
    // Do any additional setup after loading the view.
    
    self.homeTableView.estimatedRowHeight=50;
}

-(TB_TableView*)homeTableView
{
    if (!_homeTableView) {
        
        _homeTableView=[[TB_TableView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT-64) style:UITableViewStylePlain];
        
        _homeTableView.delegate=self;
        
        _homeTableView.dataSource=self;
        
        _homeTableView.tableFooterView=[[UIView alloc]init];
        
        [_homeTableView registerNib:[UINib nibWithNibName:@"SettingTableViewCell" bundle:nil] forCellReuseIdentifier:@"cell"];
        
        [_homeTableView registerNib:[UINib nibWithNibName:@"TextLabelTableViewCell" bundle:nil] forCellReuseIdentifier:@"TestCell"];
        
        [_homeTableView registerNib:[UINib nibWithNibName:@"AnswerContentTableViewCell" bundle:nil] forCellReuseIdentifier:@"AnswerContentCell"];
        
        [_homeTableView registerNib:[UINib nibWithNibName:@"AnswerTitleTableViewCell" bundle:nil] forCellReuseIdentifier:@"AnswerTitleCell"];
        
        [_homeTableView registerNib:[UINib nibWithNibName:@"QuestionsTableViewCell" bundle:nil] forCellReuseIdentifier:@"QuestionCell"];
        
        [_homeTableView registerNib:[UINib nibWithNibName:@"ExaminationTableViewCell" bundle:nil] forCellReuseIdentifier:@"ExaminationCell"];
        
        [_homeTableView registerNib:[UINib nibWithNibName:@"StandardAnswerTableViewCell" bundle:nil] forCellReuseIdentifier:@"StandardCell"];
        
    }
    
    return _homeTableView;
}


-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    
    return 2;
    
}


-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    SettingTableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];

    if (indexPath.row==0) {

        cell.TipLabel.text=@"检查大项报告";

        cell.IcoImageView.image=[UIImage imageNamed:@"PeopleWork"];

    }else{

        cell.TipLabel.text=@"检查小项报告";

        cell.IcoImageView.image=[UIImage imageNamed:@"PeopleWork"];

    }
    
    return cell;
}


-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    return 50*SCREEN_WIDTH/320.0;
}


-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    ReportReqModel *req=[ReportReqModel new];

    if ([self getUserType]==1) {
        
        req.shopId=[NSString stringWithFormat:@"%ld",[LoginStatuesModel shopId]];
        
    }else if ([self getUserType]==3)
    {
        req.marketId=[NSString stringWithFormat:@"%ld",[LoginStatuesModel getStaffId]];
        
    }else{
        
        if (self.shopid!=0) {
            
            req.shopId=[NSString stringWithFormat:@"%ld",self.shopid];
        }
        
    }
    
    if (indexPath.row==0) {
        
        ItemLargerViewController *larger=[ItemLargerViewController new];
        
        larger.ReqModel=req;
        
        [self.navigationController pushViewController:larger animated:YES];
        
        
    }else{
        
        ItemSmallViewController *small=[ItemSmallViewController new];
        
        small.ReqModel=req;
        
        [self.navigationController pushViewController:small animated:YES];
        
    }
    
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
